Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Sep 9, 2025

cover phpstan/phpstan#13385 with different loop types

  • outer loop with for() {} instead of foreach() {}
  • inner loop with for() {} instead of while() {}


foreach ($children as $child) {
if ($child instanceof Operator) {
for(;$operators !== [] && end($operators)->priority() >= $child->priority();) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test isn't faithful enough because there are no changes in NodeScopeResolver. And the same fix I did for While_ also needs to be done for For_ and many others.

$operands = [];
$operators = [];

for ($i = 0; $i < count($children); $i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the type of outer loop matters. We don't need more than one test for the same change and reported bug in src/.

@staabm staabm closed this Sep 9, 2025
@staabm staabm deleted the loops branch September 9, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants